3.1192 \(\int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx\)

Optimal. Leaf size=87 \[ -\frac{\left (a^2 d+2 a b c-b^2 d\right ) \log (\cos (e+f x))}{f}+x \left (a^2 c-2 a b d-b^2 c\right )+\frac{b (a d+b c) \tan (e+f x)}{f}+\frac{d (a+b \tan (e+f x))^2}{2 f} \]

[Out]

(a^2*c - b^2*c - 2*a*b*d)*x - ((2*a*b*c + a^2*d - b^2*d)*Log[Cos[e + f*x]])/f + (b*(b*c + a*d)*Tan[e + f*x])/f
 + (d*(a + b*Tan[e + f*x])^2)/(2*f)

________________________________________________________________________________________

Rubi [A]  time = 0.0798564, antiderivative size = 87, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.13, Rules used = {3528, 3525, 3475} \[ -\frac{\left (a^2 d+2 a b c-b^2 d\right ) \log (\cos (e+f x))}{f}+x \left (a^2 c-2 a b d-b^2 c\right )+\frac{b (a d+b c) \tan (e+f x)}{f}+\frac{d (a+b \tan (e+f x))^2}{2 f} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x]),x]

[Out]

(a^2*c - b^2*c - 2*a*b*d)*x - ((2*a*b*c + a^2*d - b^2*d)*Log[Cos[e + f*x]])/f + (b*(b*c + a*d)*Tan[e + f*x])/f
 + (d*(a + b*Tan[e + f*x])^2)/(2*f)

Rule 3528

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(d
*(a + b*Tan[e + f*x])^m)/(f*m), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx &=\frac{d (a+b \tan (e+f x))^2}{2 f}+\int (a+b \tan (e+f x)) (a c-b d+(b c+a d) \tan (e+f x)) \, dx\\ &=\left (a^2 c-b^2 c-2 a b d\right ) x+\frac{b (b c+a d) \tan (e+f x)}{f}+\frac{d (a+b \tan (e+f x))^2}{2 f}+\left (2 a b c+a^2 d-b^2 d\right ) \int \tan (e+f x) \, dx\\ &=\left (a^2 c-b^2 c-2 a b d\right ) x-\frac{\left (2 a b c+a^2 d-b^2 d\right ) \log (\cos (e+f x))}{f}+\frac{b (b c+a d) \tan (e+f x)}{f}+\frac{d (a+b \tan (e+f x))^2}{2 f}\\ \end{align*}

Mathematica [C]  time = 0.44539, size = 96, normalized size = 1.1 \[ \frac{2 b (2 a d+b c) \tan (e+f x)+(a-i b)^2 (d+i c) \log (\tan (e+f x)+i)+(a+i b)^2 (d-i c) \log (-\tan (e+f x)+i)+b^2 d \tan ^2(e+f x)}{2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x]),x]

[Out]

((a + I*b)^2*((-I)*c + d)*Log[I - Tan[e + f*x]] + (a - I*b)^2*(I*c + d)*Log[I + Tan[e + f*x]] + 2*b*(b*c + 2*a
*d)*Tan[e + f*x] + b^2*d*Tan[e + f*x]^2)/(2*f)

________________________________________________________________________________________

Maple [A]  time = 0.005, size = 151, normalized size = 1.7 \begin{align*}{\frac{{b}^{2}d \left ( \tan \left ( fx+e \right ) \right ) ^{2}}{2\,f}}+2\,{\frac{abd\tan \left ( fx+e \right ) }{f}}+{\frac{{b}^{2}c\tan \left ( fx+e \right ) }{f}}+{\frac{{a}^{2}\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) d}{2\,f}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) abc}{f}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ){b}^{2}d}{2\,f}}+{\frac{{a}^{2}\arctan \left ( \tan \left ( fx+e \right ) \right ) c}{f}}-2\,{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ) abd}{f}}-{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ){b}^{2}c}{f}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e)),x)

[Out]

1/2/f*b^2*d*tan(f*x+e)^2+2/f*a*b*d*tan(f*x+e)+1/f*b^2*c*tan(f*x+e)+1/2/f*a^2*ln(1+tan(f*x+e)^2)*d+1/f*ln(1+tan
(f*x+e)^2)*a*b*c-1/2/f*ln(1+tan(f*x+e)^2)*b^2*d+1/f*a^2*arctan(tan(f*x+e))*c-2/f*arctan(tan(f*x+e))*a*b*d-1/f*
arctan(tan(f*x+e))*b^2*c

________________________________________________________________________________________

Maxima [A]  time = 1.77721, size = 124, normalized size = 1.43 \begin{align*} \frac{b^{2} d \tan \left (f x + e\right )^{2} - 2 \,{\left (2 \, a b d -{\left (a^{2} - b^{2}\right )} c\right )}{\left (f x + e\right )} +{\left (2 \, a b c +{\left (a^{2} - b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \,{\left (b^{2} c + 2 \, a b d\right )} \tan \left (f x + e\right )}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(b^2*d*tan(f*x + e)^2 - 2*(2*a*b*d - (a^2 - b^2)*c)*(f*x + e) + (2*a*b*c + (a^2 - b^2)*d)*log(tan(f*x + e)
^2 + 1) + 2*(b^2*c + 2*a*b*d)*tan(f*x + e))/f

________________________________________________________________________________________

Fricas [A]  time = 1.47966, size = 209, normalized size = 2.4 \begin{align*} \frac{b^{2} d \tan \left (f x + e\right )^{2} - 2 \,{\left (2 \, a b d -{\left (a^{2} - b^{2}\right )} c\right )} f x -{\left (2 \, a b c +{\left (a^{2} - b^{2}\right )} d\right )} \log \left (\frac{1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 2 \,{\left (b^{2} c + 2 \, a b d\right )} \tan \left (f x + e\right )}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(b^2*d*tan(f*x + e)^2 - 2*(2*a*b*d - (a^2 - b^2)*c)*f*x - (2*a*b*c + (a^2 - b^2)*d)*log(1/(tan(f*x + e)^2
+ 1)) + 2*(b^2*c + 2*a*b*d)*tan(f*x + e))/f

________________________________________________________________________________________

Sympy [A]  time = 0.377592, size = 143, normalized size = 1.64 \begin{align*} \begin{cases} a^{2} c x + \frac{a^{2} d \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac{a b c \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - 2 a b d x + \frac{2 a b d \tan{\left (e + f x \right )}}{f} - b^{2} c x + \frac{b^{2} c \tan{\left (e + f x \right )}}{f} - \frac{b^{2} d \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac{b^{2} d \tan ^{2}{\left (e + f x \right )}}{2 f} & \text{for}\: f \neq 0 \\x \left (a + b \tan{\left (e \right )}\right )^{2} \left (c + d \tan{\left (e \right )}\right ) & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))**2*(c+d*tan(f*x+e)),x)

[Out]

Piecewise((a**2*c*x + a**2*d*log(tan(e + f*x)**2 + 1)/(2*f) + a*b*c*log(tan(e + f*x)**2 + 1)/f - 2*a*b*d*x + 2
*a*b*d*tan(e + f*x)/f - b**2*c*x + b**2*c*tan(e + f*x)/f - b**2*d*log(tan(e + f*x)**2 + 1)/(2*f) + b**2*d*tan(
e + f*x)**2/(2*f), Ne(f, 0)), (x*(a + b*tan(e))**2*(c + d*tan(e)), True))

________________________________________________________________________________________

Giac [B]  time = 1.83952, size = 1307, normalized size = 15.02 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*a^2*c*f*x*tan(f*x)^2*tan(e)^2 - 2*b^2*c*f*x*tan(f*x)^2*tan(e)^2 - 4*a*b*d*f*x*tan(f*x)^2*tan(e)^2 - 2*a
*b*c*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*ta
n(f*x)*tan(e) + 1))*tan(f*x)^2*tan(e)^2 - a^2*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e
) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)^2*tan(e)^2 + b^2*d*log(4*(tan(e)^2 + 1
)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(
f*x)^2*tan(e)^2 - 4*a^2*c*f*x*tan(f*x)*tan(e) + 4*b^2*c*f*x*tan(f*x)*tan(e) + 8*a*b*d*f*x*tan(f*x)*tan(e) + b^
2*d*tan(f*x)^2*tan(e)^2 + 4*a*b*c*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2
*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)*tan(e) + 2*a^2*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*ta
n(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)*tan(e) - 2*
b^2*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*t
an(f*x)*tan(e) + 1))*tan(f*x)*tan(e) - 2*b^2*c*tan(f*x)^2*tan(e) - 4*a*b*d*tan(f*x)^2*tan(e) - 2*b^2*c*tan(f*x
)*tan(e)^2 - 4*a*b*d*tan(f*x)*tan(e)^2 + 2*a^2*c*f*x - 2*b^2*c*f*x - 4*a*b*d*f*x + b^2*d*tan(f*x)^2 + b^2*d*ta
n(e)^2 - 2*a*b*c*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f
*x)^2 - 2*tan(f*x)*tan(e) + 1)) - a^2*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(
f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1)) + b^2*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*t
an(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1)) + 2*b^2*c*tan(f*x) + 4*a*b*d*tan
(f*x) + 2*b^2*c*tan(e) + 4*a*b*d*tan(e) + b^2*d)/(f*tan(f*x)^2*tan(e)^2 - 2*f*tan(f*x)*tan(e) + f)